import History from "./base";

export default class Hash extends History {
  constructor(router) {
    super(router)
    ensureSlash()
  }
  getCurrentLocation() {
    return window.location.hash.slice(1)
  }
  setUpListener() {
    window.addEventListener('hashchange', () => {
      console.log(this.getCurrentLocation());
      this.transitionTo(this.getCurrentLocation())
    })
  }
}
function ensureSlash() {
  if (window.location.hash) {
    return
  }
  window.location.hash="/"
}